package csel.controller.commands;

import java.util.Hashtable;

import csel.model.Entity;
import csel.model.Model;
import csel.model.GameCommand;
import csel.model.Direction;

public class MoveCommand implements GameCommand
{
	private Entity entity;
	private Character moveCharacter;
	private Hashtable<Character, Direction> moveTable = new Hashtable<Character, Direction>(12);

	//constructs a new move command based on what character was pressed
	public MoveCommand(Character keyNum, Model model)
	{
		this.moveCharacter = keyNum;
		moveTable.put('1', Direction.SOUTHWEST);
		moveTable.put('2', Direction.SOUTH);
		moveTable.put('3', Direction.SOUTHEAST);
		moveTable.put('4', Direction.WEST);
		moveTable.put('6', Direction.EAST);
		moveTable.put('7', Direction.NORTHWEST);
		moveTable.put('8', Direction.NORTH);
		moveTable.put('9', Direction.NORTHEAST);
		moveTable.put('s', Direction.SOUTH);
		moveTable.put('a', Direction.WEST);
		moveTable.put('d', Direction.EAST);
		moveTable.put('w', Direction.NORTH);
		this.entity = model.getPlayerEntity();
	}

	//calls the move command passing in a dictionary look up value
	public void execute()
	{
		if(Model.infoMode)System.out.println("[MODEL] the movement in direction "
				+ moveTable.get(moveCharacter) + " has been executed");
		 entity.move(moveTable.get(moveCharacter));
	}
	
	public String toString()
	{
		return this.getClass().getSimpleName();
	}
	
	
	/*
	 * ---------------
	 * TEST CODE ONLY
	 * ---------------
	 */
	public Character getValue()
	{
		return moveCharacter;
	}
}
